package wsi.depend.model;

import org.rygh.core.model.graph.single.SNode;

import wsi.function.Function;

public class DependencyNode extends SNode<Function, Dependency, DependencyEdge> {

	public DependencyNode(Function function) {
		super(function);
	}

	public String toXmlString() {
		if (getDegree() == 0)
			return "";

		StringBuilder sb = new StringBuilder();

		sb.append(String.format("<function name=\"%s\">", value.getName()));

		for (DependencyEdge e : edges) {
			Dependency dep = e.getValue();

			sb.append(String.format(
					"<depends_on function=\"%s\" at_xpath=\"%s\"/>", dep
							.getProvider().getName(), dep.getXpath()));
		}

		sb.append("</function>");

		return sb.toString();
	}
}
